package svgundoredo;

/**
 * This is a stroke command class
 */
import svgedit.svg.SVGLength;
import svgedit.svg.SVGStylable;

public class StroketElementCommand extends AbstractCommand
{
    private SVGStylable elem;
    private SVGLength strokeWidth;
    private String old, newStrok;
    
    /**
     * @param elem
     *            The current selected stroke width
     * @param strokeWidth
     *            the new stroke width
     */
    public StroketElementCommand(SVGStylable elem, SVGLength strokeWidth)
    {
        this.strokeWidth = strokeWidth;
        this.elem = elem;
        old = elem.getStrokeWidth().valueAsString();
        newStrok = strokeWidth.valueAsString();
    }
    
    @Override
    public void execute()
    {
        strokeWidth.setValueFromString(newStrok);
        elem.getStrokeWidth().setValueFromLength(strokeWidth);
        // System.out.println(old.valueAsString()+ " " +
        // strokeWidth.valueAsString());
    }
    
    @Override
    public void undo()
    {
        strokeWidth.setValueFromString(old);
        elem.getStrokeWidth().setValueFromLength(strokeWidth);
        
    }
    
}
